package com.eyepax.assignment.title.core.main;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.eyepax.assignment.title.core.configurer.SpringBeanConfigurer;
import com.eyepax.assignment.title.core.exception.ModuleCommonsException;
import com.eyepax.assignment.title.core.util.UtilityProperties;

/**
 * The Main Class which runs the Application
 * 
 * @author Rukshan Silva | 02nd July 2014
 * @version 1.0.0
 */
public class JavaAssignmentApplication {

	private SpringBeanConfigurer springBeanConfigurer;
	
	public void initializeApplication() {
		
		ApplicationContext applicationContext = new FileSystemXmlApplicationContext("resources/applicationContext.xml");
		
		springBeanConfigurer = (SpringBeanConfigurer) applicationContext.getBean("beanConfigurer");
		
		springBeanConfigurer.initializeLog();
		
		try {
			springBeanConfigurer.initializeProperties();
		} catch (ModuleCommonsException e) {
			e.printStackTrace();
		}
	}
	
	public String invokeService1() {

		System.out.println(UtilityProperties.DEVELOPER_NAME);
		/**
		 * Process the Business Logic
		 */
		
		return springBeanConfigurer.invokeService1(); 
	}
	
	public String invokeService2() {

		/**
		 * Process the Business Logic
		 */
		
		return springBeanConfigurer.invokeService2("Rukshan"); 
	}
}
